package com.augurit.agmobile.agwater5.drainage.supervise.adapter

import android.app.Activity
import android.view.View
import android.widget.TextView
import androidx.core.graphics.toColorInt
import com.augurit.agmobile.agwater5.drainage.supervise.model.ShowType
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseType
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseVariousItemBean
import com.augurit.agmobile.agwater5.drainage.supervise.view.SuperviseItemDetailActivity
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.arm.ext.dpInt
import com.example.drainage.R
import com.example.drainage.base.ktexpand.setBackgroundByDrawable

/**
 * @author 创建人 ：yanghaozhang
 * @version 1.0
 * @package 包名 ：com.augurit.agmobile.agwater5.drainage.supervise.adapter
 * @createTime 创建时间 ：2022/1/5
 * @modifyBy 修改人 ：
 * @modifyTime 修改时间 ：
 * @modifyMemo 修改备注：
 */
class SuperviseVariousItemAdapter : BaseQuickAdapter<SuperviseVariousItemBean, BaseViewHolder>(R.layout.item_supervise_various_item) {

    override fun convert(holder: BaseViewHolder, item: SuperviseVariousItemBean) {
        holder.setText(R.id.tvItemName, item.itemName)
        holder.getView<TextView>(R.id.tvItemStatus).apply {
            text = item.statusName
            setBackgroundByDrawable(2.dpInt, fillColor = getColorByStatusName(item.statusName))
        }
        holder.getView<View>(R.id.ivRightArrow).setOnClickListener {
            SuperviseItemDetailActivity.jump(context as Activity, SuperviseType.Reservoir, "", ShowType.Editable)
        }
    }

    private fun getColorByStatusName(statusName: String): Int {
        return when (statusName) {
            "未检查" -> "#FFC5CDD9"
            "正常" -> "#FF38C466"
            "一般" -> "#FF1A7AFE"
            "较重" -> "#FFFDA22D"
            "严重" -> "#FFF7405A"
            "特别严重" -> "#FFAA0048"
            else -> "#FF20C2C8"
        }.toColorInt()
    }
}